<?php

use Webman\Route;
use Webman\Http\Request;






Route::group('/admin/kt', function () {
    Route::get('/index', [app\controller\UserController::class, 'index']);
    Route::post('/manualCards/add', [app\controller\UserController::class, 'manualCardsadd'])->name('admin.manual.cards.add');
    Route::post('/addMoney', [app\api\controller\WalletsController::class, 'addMoney'])->name('api.manual.addMoney');



})->middleware(plugin\admin\api\Middleware::class);



Route::group('/api', function () {
    Route::get('/test', [app\api\controller\TestController::class, 'test']); //注册接口-验证码
    Route::get('/queryData', [app\api\controller\WalletsController::class, 'queryData'])->name('api.admin.queryData');      //查询某天数据

    //用户信息
    Route::group('/user', function () {
        //不需要token的接口
        Route::get('/test', [app\api\controller\UserController::class, 'test']); //注册接口-验证码
        Route::get('/test1', [app\api\controller\UserController::class, 'test1']); //ceshi 码
        Route::get('/sendCode', [app\api\controller\UserController::class, 'sendCode']);
        Route::post('/register', [app\api\controller\UserController::class, 'register'])->name('api.user.register'); //注册接口-验证码
        Route::post('/registerTo', [app\api\controller\UserController::class, 'registerTo'])->name('api.user.registerTo'); //注册接口-设置密码
        Route::post('/login', [app\api\controller\UserController::class, 'login'])->name('api.user.login'); //登录接口
//        Route::group('/common', function () {
//            Route::post('/upload', [app\api\controller\CommonController::class, 'upload'])->name('api.common.upload'); //上传图片
//            Route::get('/icon/list', [app\api\controller\CommonController::class, 'icon_list'])->name('api.common.icon_list'); //获取公司列表
//        });
    });

});

Route::group('/api', function () {
    //用户信息
    Route::group('/user', function () {
        Route::post('/changePassword', [app\api\controller\UserController::class, 'changePassword'])->name('api.user.changePassword'); //修改密碼
        Route::post('/changeTradePassword', [app\api\controller\UserController::class, 'changeTradePassword'])->name('api.user.changeTradePassword'); //修改交易密码
        Route::post('/changeAuthPassword', [app\api\controller\UserController::class, 'changeAuthPassword'])->name('api.user.changeAuthPassword'); //修改二级安全码密码
        Route::post('/lockAuthPassword', [app\api\controller\UserController::class, 'lockAuthPassword']); //开启、禁用二级安全码
        Route::post('/updateUserInfo', [app\api\controller\UserController::class, 'updateUserInfo'])->name('api.user.updateUserInfo'); //更新個人信息
        Route::get('/userInfo', [app\api\controller\UserController::class, 'userInfo'])->name('api.user.userInfo');

        //调账列表
        Route::get('/eggsList', [app\api\controller\UserController::class, 'eggsList']);
        Route::get('/cardsList', [app\api\controller\UserController::class, 'cardsList']);
        Route::get('/yueList', [app\api\controller\UserController::class, 'yueList']);

    });
    //母鸡卡模块设置
    Route::group('/chickenCards', function () {
        Route::get('/getHenInfo', [app\api\controller\ChickenCardsController::class, 'getHenInfo'])->name('api.chickenCards.getHenInfo');
        Route::post('/add', [app\api\controller\ChickenCardsController::class, 'add'])->name('api.chickenCards.add');
        Route::post('/update', [app\api\controller\ChickenCardsController::class, 'update'])->name('api.chickenCards.update');
    });
    //后台参数设置
    Route::group('/adminConfigs', function () {
        Route::get('/getAdminInfo', [app\api\controller\AdminConfigsController::class, 'getAdminInfo']);
        Route::post('/add', [app\api\controller\AdminConfigsController::class, 'add'])->name('api.adminConfigs.add');
        Route::post('/update', [app\api\controller\AdminConfigsController::class, 'update'])->name('api.adminConfigs.update');
        Route::get('/pay_type', [app\api\controller\AdminConfigsController::class, 'pay_type']);
    });
    //邀请信息
    Route::group('/inviteRecord', function () {
        Route::get('/list', [app\api\controller\InviteRecordController::class, 'list']);
        Route::post('/exchange', [app\api\controller\InviteRecordController::class, 'exchange']);
        Route::get('/inviteInfo', [app\api\controller\InviteRecordController::class, 'inviteInfo']);
    });
    //手动发卡
    Route::group('/manualCards', function () {
        Route::post('/add', [app\api\controller\ManualCardsController::class, 'add'])->name('api.manualCards.add');
        Route::get('/list', [app\api\controller\ManualCardsController::class, 'list']);

    });
    //钱包
    Route::group('/wallets', function () {
        Route::get('/info', [app\api\controller\WalletsController::class, 'info'])->name('api.wallets.info');
        Route::post('/buyCards', [app\api\controller\WalletsController::class, 'buyCards'])->name('api.wallets.buyCards');
        Route::get('/buyCardsList', [app\api\controller\WalletsController::class, 'buyCardsList'])->name('api.wallets.buyCardsList');
        Route::post('/useProducedEggs', [app\api\controller\WalletsController::class, 'useProducedEggs']);
        Route::post('/useCard', [app\api\controller\WalletsController::class, 'useCard'])->name('api.wallets.useCard');
        Route::post('/compositeCard', [app\api\controller\WalletsController::class, 'compositeCard'])->name('api.wallets.compositeCard');
        Route::post('/giftEgg', [app\api\controller\WalletsController::class, 'giftEgg'])->name('api.wallets.giftEgg');
        Route::get('/giftEggList', [app\api\controller\WalletsController::class, 'giftEggList'])->name('api.wallets.giftEggList');
        Route::post('/getUseCardInfo', [app\api\controller\WalletsController::class, 'getUseCardInfo']);

    });
    //疯狂赛车游戏
    Route::group('/gameCar', function () {
        Route::get('/test', [app\api\controller\GameCarController::class, 'test'])->name('api.gameCar.test');
        Route::get('/list', [app\api\controller\GameCarController::class, 'list'])->name('api.gameCar.list');
        Route::post('/add', [app\api\controller\GameCarController::class, 'add'])->name('api.gameCar.add');
        Route::post('/openGame', [app\api\controller\GameCarController::class, 'openGame'])->name('api.gameCar.openGame');
        Route::get('/getNowGame', [app\api\controller\GameCarController::class, 'getNowGame']);   //获取当前游戏数据
        Route::post('/playGame', [app\api\controller\GameCarController::class, 'playGame']);   //投注当前游戏数据
        Route::get('/playGameList', [app\api\controller\GameCarController::class, 'playGameList']);   //用户押注列表
//        Route::post('/gotPrize', [app\api\controller\GameCarController::class, 'gotPrize']);   //投注当前游戏数据
    });


    //聚宝盆游戏
    Route::group('/gameBowl', function () {
        Route::get('/list', [app\api\controller\GameBowlController::class, 'list']);
        Route::post('/add', [app\api\controller\GameBowlController::class, 'add']);
        Route::get('/getNowGame', [app\api\controller\GameBowlController::class, 'getNowGame']);   //获取当天游戏
        Route::post('/openGame', [app\api\controller\GameBowlController::class, 'openGame']);   //开奖
//        Route::post('/gotPrize', [app\api\controller\GameBowlController::class, 'gotPrize']);   //兑奖
        Route::post('/playGame', [app\api\controller\GameBowlController::class, 'playGame']);   //押注
        Route::get('/playGameList', [app\api\controller\GameBowlController::class, 'playGameList']);   //押注列表
        Route::get('/gotPriceList', [app\api\controller\GameBowlController::class, 'gotPriceList']);   //获取中奖信息
        Route::get('/historyDateId', [app\api\controller\GameBowlController::class, 'historyDateId']);   //获取历史期号
         //投注当前游戏数据
    });

    //猫狗斗游戏
    Route::group('/game2', function () {
        Route::get('/list', [app\api\controller\Game2Controller::class, 'list']);
        Route::post('/add', [app\api\controller\Game2Controller::class, 'add']);
        Route::post('/playGame', [app\api\controller\Game2Controller::class, 'playGame']);   //押注
        Route::get('/playGameList', [app\api\controller\Game2Controller::class, 'playGameList']);
        Route::get('/getNowGame', [app\api\controller\Game2Controller::class, 'getNowGame']);   //获取当前游戏
        Route::get('/getDateIdList', [app\api\controller\Game2Controller::class, 'getDateIdList']);   //获取某期号的游戏记录
        Route::get('/getDateIdInfo', [app\api\controller\Game2Controller::class, 'getDateIdInfo']);   //获取某期号的游戏
        Route::post('/openGame', [app\api\controller\Game2Controller::class, 'openGame']);   //开奖
        Route::post('/userOpenGame', [app\api\controller\Game2Controller::class, 'userOpenGame']);   //用户开奖
//        Route::post('/gotPrize', [app\api\controller\Game2Controller::class, 'gotPrize']);   //兑奖
        Route::get('/updatePrize', [app\api\controller\Game2Controller::class, 'updatePrize']);   //奖励发送
    });
    //支付相关
    Route::group('/payGuide', function () {
        Route::post('/pay', [app\api\controller\PayGuideController::class, 'pay']);
        Route::post('/payUser', [app\api\controller\PayGuideController::class, 'payUser']);
        Route::get('/payList', [app\api\controller\PayGuideController::class, 'payList']);
        Route::post('/query', [app\api\controller\PayGuideController::class, 'query']);
        Route::post('/query_balance', [app\api\controller\PayGuideController::class, 'query_balance']);
    });

})->middleware(app\middleware\AuthUser::class);

Route::group('/controller', function () {
    Route::group('/admin', function () {
        //不需要token的接口
        Route::post('/index', [app\controller\UserController::class, 'index']);
        Route::post('/login', [app\controller\UserController::class, 'login']);
        Route::get('/userInfo', [app\controller\UserController::class, 'userInfo']);
        Route::get('/manualCardsList', [app\controller\UserController::class, 'manualCardsList']);
        Route::post('/manualCards/add', [app\controller\UserController::class, 'manualCardsadd']);
        Route::get('/payList', [app\controller\UserController::class, 'payList']);
        Route::post('/payAdd', [app\controller\UserController::class, 'payAdd']);
        Route::post('/payDel', [app\controller\UserController::class, 'payDel']);
        Route::post('/payUpdate', [app\controller\UserController::class, 'payUpdate']);

    });

});


Route::fallback(function (Request $request) {
    $response = strtoupper($request->method()) === 'OPTIONS' ? response('', 204) : response('', 404);
    $response->withHeaders([
        'Access-Control-Allow-Credentials' => 'true',
        'Access-Control-Allow-Origin' => "*",
        'Access-Control-Allow-Methods' => '*',
        'Access-Control-Allow-Headers' => '*',
    ]);
    return $response;
});



//关闭默认路由
Route::disableDefaultRoute();

